package com.wd.live.view.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.wd.live.R
import com.wd.live.model.bean.ZhiBoListBean

/**
 * 作者：马海钊
 * 时间：2023/8/18 11:48
 * 功能：
 */
class LiveRecyAdapter(private val context: Context,private val list: List<ZhiBoListBean.Result>) : RecyclerView.Adapter<LiveRecyAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.fujin_recy_xiao, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.qianming.text = list!![position].liveTitle
        holder.name.text = list!![position].nickName
        Glide.with(context!!)
            .load(list!![position].liveCoverUrl)
            .error(R.mipmap.xiao)
            .placeholder(R.mipmap.xiao)
            .circleCrop()
            .into(holder.imgid)
        if (list.get(position).sex==1){
            Glide.with(context).load(R.mipmap.my_man).into(holder.sexid)
        }else{
            Glide.with(context).load(R.mipmap.my_woman).into(holder.sexid)
        }

    }

    override fun getItemCount(): Int {
        return list!!.size
    }

    inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var imgid: ImageView
        var sexid: ImageView
        var name: TextView
        var qianming: TextView

        init {
            imgid = itemView.findViewById(R.id.fujin_recy_head_imgid)
            sexid = itemView.findViewById(R.id.fujin_recy_sexid)
            name = itemView.findViewById(R.id.fujin_recy_nameid)
            qianming = itemView.findViewById(R.id.fujin_recy_style_nameid)
        }
    }
}